import sys
import os


for file in os.listdir(sys.argv[1]):
    
    if file.endswith('.pav.txt'):
    # if file.endswith('pav.txt'):
        ration_dict={}
        op_file=open(file,'r')
        for line in op_file:
            line_list=line.strip().split()
            if line_list[0] not in ration_dict.keys():
                ration_dict[line_list[0]]=[int(line_list[1]),0]
            if line_list[2]!='no':
                ration_dict[line_list[0]][1]+=1
        index=0
        op_file.close() 
        key_list=[]   
        for key,value in ration_dict.items():
            index+=value[1]
            if value[1]/value[0]>0.3:
                
                key_list.append(key)
            
        print(file,index)
        op_file=open(file,'r')
        out_file=open(file+'.psedu','w')
        for line in op_file:
            line_list=line.strip().split('\t')
            if line_list[0] in key_list:
                continue
            else:
                out_file.write(line)
                
